#include <atomic>
#include <sys/time.h>
#include <stdio.h>
using namespace std;
int gettime(int i)
{
    static struct timeval tv1;
    struct timeval tv2;
    if(i == 0)
    {
        gettimeofday(&tv1, NULL);
        return 0;
    }else
    {
        gettimeofday(&tv2, NULL);
        return tv2.tv_sec * 1000000 + tv2.tv_usec - tv1.tv_sec * 1000000 - tv1.tv_usec;
    }

}
int main(int argc, char *argv[])
{
    atomic_int m;
    atomic_llong n;
    long long a;
    int time;
    printf("size = %d\n", sizeof(m));
    printf("size = %d\n", sizeof(n));




    gettime(0);
    for (int i = 0; i < 10000; i++) {
        m++;
    }
    time = gettime(1);
    printf("time = %d\n", time);

    gettime(0);
    for (int i = 0; i < 10000; i++) {
        n++;
    }
    time = gettime(1);
    printf("time = %d\n", time);


    gettime(0);
    for (int i = 0; i < 10000; i++) {
        a++;
    }
    time = gettime(1);
    printf("time = %d\n", time);



    return 0;
}
